﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PurchasePlan.ascx.cs"
    Inherits="HHMMS.UI.Modules.Workflow.Forms.PurchasePlan" %>
<asp:TextBox ID="tbDocId" Name="DocId" runat="server" Style="display: none;"></asp:TextBox>
<table cellpadding="2" cellspacing="1" width="100%" class="formitem" style="border: 0;" _disable_="(*.审核)(*.审批)(*.办理采购手续)(*.结束)">
    <tr>
        <th>
            标题:<span style="color: Red;">*</span>
        </th>
        <td>
            <asp:TextBox ID="tbTitle" Name="Title" runat="server" Width="310px" validator="required,length[1,50]"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <th>
            单号:
        </th>
        <td>
            <asp:Label ID="lbWFInstanceId" Name="WFInstanceId" runat="server" Text="保存后生成"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <span style="display:none; color:Red;" _visible_="(*.办理采购手续)">注：提交任务前请填写每个采购配件的到货日期。</span>
        </td>
        <td style="text-align: right;">
            <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="return openForm(this, 'Insert');" style="display:none;" _visible_="(*.编制采购计划)"
                OnClick="SearchGrid">
                <span>
                    <img id="Img1" alt="" runat="server" src="~/Images/icon_new.gif" style="border: 0px" />添加配件
                </span>
            </asp:LinkButton>
        </td>
    </tr>
</table>
<web:SmartGridView ID="gridParts" runat="server" AutoGenerateColumns="False" Width="100%"
    DataKeyNames="DocId" DataSourceID="SmartDataSource1" PageSize="10">
    <Columns>
        <asp:BoundField DataField="PartName" HeaderText="配件名称" SortExpression="PartName"
            ItemStyle-HorizontalAlign="Left" />
        <asp:BoundField DataField="PartModel" HeaderText="配件型号规格" SortExpression="PartModel"
            ItemStyle-HorizontalAlign="Center" />
        <asp:BoundField DataField="Unit" HeaderText="单位" SortExpression="Unit" ItemStyle-HorizontalAlign="Center" />
        <asp:BoundField DataField="Count" HeaderText="计划采购数量" SortExpression="Count" ItemStyle-HorizontalAlign="Center" />
        <asp:BoundField DataField="ApplyGroup" HeaderText="申请及使用班组" SortExpression="ApplyGroup"
            ItemStyle-HorizontalAlign="Center" />
        <asp:BoundField DataField="MaterialPlanUser" HeaderText="材料计划员" SortExpression="MaterialPlanUser"
            ItemStyle-HorizontalAlign="Center" />
        <%--<asp:BoundField DataField="Demand" HeaderText="有关要求" SortExpression="Demand" ItemStyle-HorizontalAlign="Left" />
        <asp:BoundField DataField="Remark" HeaderText="备注" SortExpression="Remark" ItemStyle-HorizontalAlign="Left" />--%>
        <asp:BoundField DataField="ArrivalDate" HeaderText="到货日期" SortExpression="ArrivalDate" DataFormatString="{0:yyyy-MM-dd}"
            ItemStyle-HorizontalAlign="Center" />
        <asp:TemplateField HeaderText="操作">
            <ItemStyle HorizontalAlign="Center" />
            <HeaderStyle Wrap="False" HorizontalAlign="Center" />
            <ItemTemplate>
                <table width="46px">
                    <tr>
                        <td style="border: 0px solid #fff;">
                            <asp:ImageButton ID="ImageButton1" runat="server" ToolTip="编辑" _ID='<%#Eval("DocId")%>' style="display:none;" _visible_="(*.编制采购计划)(1.办理采购手续)"
                                _PartName='<%#Eval("PartName")%>' _PartModel='<%#Eval("PartModel")%>' ImageUrl="~/images/com/dg_edit.gif"
                                CausesValidation="False" OnClientClick="return openForm(this, 'Edit');" OnClick="RefreshGrid">
                            </asp:ImageButton>
                        </td>
                        <td style="border: 0px solid #fff;">
                            <asp:ImageButton ID="ImageButton2" runat="server" ToolTip="删除" _ID='<%#Eval("DocId")%>' style="display:none;" _visible_="(*.编制采购计划)"
                                _PartName='<%#Eval("PartName")%>' _PartModel='<%#Eval("PartModel")%>' ImageUrl="~/images/com/dg_del.gif"
                                CausesValidation="False" OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeletePurchaseSuppliesPlan">
                            </asp:ImageButton>
                        </td>
                        <td style="border: 0px solid #fff;">
                            <asp:ImageButton ID="ImageButton3" runat="server" ToolTip="查看" _ID='<%#Eval("DocId")%>'
                                _PartName='<%#Eval("PartName")%>' _PartModel='<%#Eval("PartModel")%>' ImageUrl="~/images/ico_search.gif"
                                CausesValidation="False" OnClientClick="return openForm(this, 'View');" OnClick="RefreshGrid">
                            </asp:ImageButton>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <PagerSettings />
    <EditRowStyle HorizontalAlign="Center" />
</web:SmartGridView>
<web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="PlanManager.PurchaseSuppliesPlan.List"
    SelectCountCommand="PlanManager.PurchaseSuppliesPlan.List.Count" DefaultSortExpression="DocId DESC"
    SelectCommandAutoPageWrap="true">
</web:SmartSqlDataSource>
<script type="text/javascript">
    function openForm(_this, action) {
        var url = Global.contextPath + "/Modules/PlanManager/PurchaseSuppliesPlanEdit.aspx";
        var docId = $("input[id$='tbDocId']").val();
        if (!docId || docId == '') {
            alert("请选保存后再添加配件！");
            return false;
        }

        // FormViewMode : Insert/Edit/ReadOnly
        var params = {
            FormViewMode: action,
            DocId: docId,
            activityName: activityName,
            actionType: actionType
        }
        if (action == "Insert") {
            //params.title = "新增采购配件";
        } else if (action == "Edit") {
            //params.title = "编辑采购配件";
            params.PartName = $(_this).attr("_PartName");
            params.PartModel = $(_this).attr("_PartModel");
        } else if (action == "View") {
            url = Global.contextPath + "/Modules/PlanManager/PurchaseSuppliesPlanView.aspx";
            params.title = "采购计划物资信息编辑";
            params.PartName = $(_this).attr("_PartName");
            params.PartModel = $(_this).attr("_PartModel");
        }

        var returnValue = showCenterModalDialog(buildUrl(url, params), 780, 340, null);
        return returnValue == "true";
    }          
</script>
